<?php

namespace km\log;

/**
 * EmailLogger
 *
 * @author vbolshov
 */
class EmailLogger extends Logger {
	private $to, $from, $subject;
	function __construct($to, $subject = null, $from = null)
	{
		$this->to = $to;
		$this->subject = $subject;
		$this->from = $from;
	}
	protected function doFinalize()
	{
		$subject = $this->subject ?: ("Error log for " . date("Y-m-d H:i:s"));
		$headers = $this->from ? ("From: {$this->from}") : null;
		mail($this->to, $subject, $this->getMessageString(), $headers);
	}
}